package com.hospital.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hospital.entity.Treatment;
import com.hospital.mapper.TreatmentMapper;
import com.hospital.service.TreatmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TreatmentServiceImpl implements TreatmentService {
    @Autowired
    private TreatmentMapper treatmentMapper;

    @Override
    public Long assignTreatment(Long deptId) {
//        Treatment treatment = treatmentMapper.selectOne(
//                new LambdaQueryWrapper<Treatment>()
//                        .eq(Treatment::getDeptId, deptId)
//                        .last("ORDER BY RAND() LIMIT 1")
//        );
        Treatment treatment = treatmentMapper.getRandomTreatmentByDeptId(deptId);

        return treatment.getTreatmentId();
    }
}
